import express from 'express'
import { getApiDailyStats } from '../controllers/apiDailyStatsController.js'

const router = express.Router()

/**
 * @swagger
 * /api-daily-stats:
 *   get:
 *     summary: 获取API请求日报
 *     description: 获取指定日期范围内的接口请求统计信息
 *     parameters:
 *       - in: query
 *         name: startDate
 *         required: true
 *         schema:
 *           type: string
 *           format: date
 *         description: 开始日期（格式YYYY-MM-DD）
 *       - in: query
 *         name: endDate
 *         required: true
 *         schema:
 *           type: string
 *           format: date
 *         description: 结束日期（格式YYYY-MM-DD）
 *       - in: query
 *         name: userId
 *         schema:
 *           type: string
 *         description: 用户标识
 *     responses:
 *       200:
 *         description: 成功获取日报数据
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 code:
 *                   type: integer
 *                   example: 200
 *                 data:
 *                   type: object
 *                   properties:
 *                     totalRequests:
 *                       type: integer
 *                       example: 2450
 *                     successRate:
 *                       type: number
 *                       example: 99.2
 *                     avgResponseTime:
 *                       type: integer
 *                       example: 156
 *                     topApis:
 *                       type: array
 *                       items:
 *                         type: object
 *                         properties:
 *                           apiPath:
 *                             type: string
 *                             example: "/user-info"
 *                           count:
 *                             type: integer
 *                             example: 1200
 *       400:
 *         description: 日期格式错误或时间范围超过30天
 *       403:
 *         description: 无数据查看权限
 *       500:
 *         description: 服务器内部错误
 */

router.get('/',async (req, res) =>  {
    return await getApiDailyStats(req, res)
})
export default router